using System;
using System.Collections.Generic;
using UnityEngine.UIElements;
using MinesweeperPlus.Scripts.Configs;

namespace MinesweeperPlus.Scripts.UI
{
    public sealed class ShopPanel : UIElement
    {
        public new class UxmlFactory : UxmlFactory<ShopPanel> { }

        #region Actions
        public Action<ColorSchemePanel> OnColorSchemePanelClick;
        #endregion

        #region Properties
        public List<ColorSchemePanel> ColorSchemePanels { get; private set; }
        #endregion

        #region ShopPanel Methods
        public ShopPanel() : base() { }
        public ShopPanel(IconsConfig iconsConfig, StyleSheet styleSheet) : 
            base(iconsConfig, styleSheet) { }

        public void AddColorSchemePanel(ColorSchemeConfig colorSchemeConfig)
        {
            var colorSchemePanel = new ColorSchemePanel(IconsConfig, StyleSheet, colorSchemeConfig);
            colorSchemePanel.OnSelect += (colorSchemeConfig) => 
                OnColorSchemePanelClick?.Invoke(colorSchemePanel);
            ColorSchemePanels.Add(colorSchemePanel);
            Panel.Add(colorSchemePanel);
        }
        #endregion

        #region Other Methods
        protected override void CreatePanel()
        {
            Panel = this;

            ColorSchemePanels = new();
        }
        #endregion
    }
}
